/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.remote;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.suspend.localapp.ApkInstallationReceiver;
import java.util.HashMap;
import java.util.Map;

public class QRemoteService extends Service {
    private static QRemoteService b;
    private static Map c = new HashMap();
    private static Map d = new HashMap();

    @SuppressLint({ "HandlerLeak" })
    Handler a = new Handler() {
        public void handleMessage(Message paramMessage) {
            super.handleMessage(paramMessage);
            if (paramMessage.what != 0)
                return;
            QRemoteService.a(QRemoteService.this, false);
        }
    };
    private boolean e = false;
    private ApkInstallationReceiver f;
    private BroadcastReceiver g = new BroadcastReceiver() {
        public void onReceive(Context paramContext, Intent paramIntent) {
            if ((paramContext == null) || (paramIntent == null))
                return;
            String str1 = paramIntent.getAction();
            if (TextUtils.isEmpty(str1))
                return;
            if (!("com.qihoo.gamecenter.float_sdk_setting_change_broadcast".equals(str1)))
                return;
            String str2 = paramIntent.getStringExtra("com.qihoo.gamecenter.float_sdk_curr_game_pkgname");
            if (TextUtils.isEmpty(str2))
                return;
            Message localMessage = new Message();
            localMessage.what = 3;
            localMessage.obj = str2;
            b.b().a.sendMessage(localMessage);
        }
    };

    public void onCreate() {
        super.onCreate();
        b = this;
        b();
        d();
        com.qihoo.gamecenter.sdk.suspend.c.a.a(getApplicationContext(), false);
        com.qihoo.gamecenter.sdk.suspend.c.a.b(getApplicationContext(), "");
        b.b().a(this);
        this.e = false;
    }

    public static QRemoteService a() {
        return b;
    }

    public IBinder onBind(Intent paramIntent) {
        return new c(this, paramIntent);
    }

    public void onDestroy() {
        super.onDestroy();
        c();
        e();
        b.b().i();
        com.qihoo.gamecenter.sdk.suspend.c.a.a(getApplicationContext(), false);
        com.qihoo.gamecenter.sdk.suspend.c.a.b(getApplicationContext(), "");
        this.e = false;
    }

    public void a(String paramString1, String paramString2, String paramString3) {
        if (TextUtils.isEmpty(paramString1))
            return;
        b(paramString1, paramString2);
        a(paramString1, paramString3);
        if ((TextUtils.isEmpty(b.b().c())) || (!(paramString1.equals(b.b().c()))))
            return;
        String str = paramString1;
        if (this.e)
            return;
        this.e = true;
        this.a.postDelayed(new Runnable(str) {
            public void run() {
                b.b().e(this.b);
                QRemoteService.this.a.sendEmptyMessage(0);
            }
        }, 3000L);
    }

    private void a(String paramString1, String paramString2) {
        if (TextUtils.isEmpty(paramString1))
            return;
        c.put(paramString1, paramString2);
    }

    private void b(String paramString1, String paramString2) {
        if (TextUtils.isEmpty(paramString1))
            return;
        d.put(paramString1, paramString2);
    }

    public String a(String paramString) {
        String str = "";
        if (TextUtils.isEmpty(paramString))
            return str;
        if (c != null)
            str = (String) c.get(paramString);
        return str;
    }

    public String b(String paramString) {
        String str = "";
        if (TextUtils.isEmpty(paramString))
            return str;
        if (d != null)
            str = (String) d.get(paramString);
        return str;
    }

    private void b() {
        if (this.f != null)
            return;
        this.f = new ApkInstallationReceiver();
        com.qihoo.gamecenter.sdk.suspend.localapp.a.a(this, this.f);
    }

    private void c() {
        if (this.f == null)
            return;
        com.qihoo.gamecenter.sdk.suspend.localapp.a.b(this, this.f);
        this.f = null;
    }

    private void d() {
        com.qihoo.gamecenter.sdk.suspend.floatdialog.a.a(this, this.g);
    }

    private void e() {
        com.qihoo.gamecenter.sdk.suspend.floatdialog.a.b(this, this.g);
    }
}